﻿using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using WinLib.DBUtility;
namespace WinLib.DAL
{
    /// <summary>
    /// 数据访问类:SSO_UserBaseInfo
    /// </summary>
    public partial class SSO_UserBaseInfo
    {
        public SSO_UserBaseInfo()
        { }
        #region  BasicMethod
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(int SYSID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) from SSO_UserBaseInfo");
            strSql.Append(" where SYSID=@SYSID");
            SqlParameter[] parameters = {
					new SqlParameter("@SYSID", SqlDbType.Int,4)
			};
            parameters[0].Value = SYSID;

            object obj = DbHelperSQL.ExecuteScalar(strSql.ToString(), parameters);
            if (obj != null && int.Parse(obj.ToString()) > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }


        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(WinLib.Model.SSO_UserBaseInfo model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into SSO_UserBaseInfo(");
            strSql.Append("RealName,UserCode,password,UnitName,DepartName,UnitAddress,Telephone,PostCode,Email,IsHasExtend,IsHasMap,IsHasRole,IdentificationCard,CreateTime,UserDescript,IsManager,RECFLAG,UserFlag,Sex,JoinDate,EndDate,Question,Answer,IP,Birth,Positions,Education,LibraryCard,CellPhone,Jobs,City,County,IPFrom,IPTo,UserRole,RoleRight,AppCode,ReqCode,RealPassword,CardType,Country,Province,Fax,RoamFlag,RegCode,LoginCount)");
            strSql.Append(" values (");
            strSql.Append("@RealName,@UserCode,@password,@UnitName,@DepartName,@UnitAddress,@Telephone,@PostCode,@Email,@IsHasExtend,@IsHasMap,@IsHasRole,@IdentificationCard,@CreateTime,@UserDescript,@IsManager,@RECFLAG,@UserFlag,@Sex,@JoinDate,@EndDate,@Question,@Answer,@IP,@Birth,@Positions,@Education,@LibraryCard,@CellPhone,@Jobs,@City,@County,@IPFrom,@IPTo,@UserRole,@RoleRight,@AppCode,@ReqCode,@RealPassword,@CardType,@Country,@Province,@Fax,@RoamFlag,@RegCode,@LoginCount)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters = {
					new SqlParameter("@RealName", SqlDbType.NVarChar,50),
					new SqlParameter("@UserCode", SqlDbType.NVarChar,50),
					new SqlParameter("@password", SqlDbType.NVarChar,50),
					new SqlParameter("@UnitName", SqlDbType.NVarChar,200),
					new SqlParameter("@DepartName", SqlDbType.NVarChar,200),
					new SqlParameter("@UnitAddress", SqlDbType.NVarChar,500),
					new SqlParameter("@Telephone", SqlDbType.NVarChar,50),
					new SqlParameter("@PostCode", SqlDbType.VarChar,50),
					new SqlParameter("@Email", SqlDbType.NVarChar,50),
					new SqlParameter("@IsHasExtend", SqlDbType.Int,4),
					new SqlParameter("@IsHasMap", SqlDbType.Int,4),
					new SqlParameter("@IsHasRole", SqlDbType.Int,4),
					new SqlParameter("@IdentificationCard", SqlDbType.VarChar,100),
					new SqlParameter("@CreateTime", SqlDbType.DateTime),
					new SqlParameter("@UserDescript", SqlDbType.NText),
					new SqlParameter("@IsManager", SqlDbType.Int,4),
					new SqlParameter("@RECFLAG", SqlDbType.Int,4),
					new SqlParameter("@UserFlag", SqlDbType.Int,4),
					new SqlParameter("@Sex", SqlDbType.Int,4),
					new SqlParameter("@JoinDate", SqlDbType.DateTime),
					new SqlParameter("@EndDate", SqlDbType.DateTime),
					new SqlParameter("@Question", SqlDbType.NVarChar,300),
					new SqlParameter("@Answer", SqlDbType.NVarChar,300),
					new SqlParameter("@IP", SqlDbType.VarChar,50),
					new SqlParameter("@Birth", SqlDbType.DateTime),
					new SqlParameter("@Positions", SqlDbType.VarChar,50),
					new SqlParameter("@Education", SqlDbType.VarChar,50),
					new SqlParameter("@LibraryCard", SqlDbType.VarChar,50),
					new SqlParameter("@CellPhone", SqlDbType.VarChar,50),
					new SqlParameter("@Jobs", SqlDbType.VarChar,50),
					new SqlParameter("@City", SqlDbType.VarChar,50),
					new SqlParameter("@County", SqlDbType.VarChar,50),
					new SqlParameter("@IPFrom", SqlDbType.VarChar,50),
					new SqlParameter("@IPTo", SqlDbType.VarChar,50),
					new SqlParameter("@UserRole", SqlDbType.Int,4),
					new SqlParameter("@RoleRight", SqlDbType.Int,4),
					new SqlParameter("@AppCode", SqlDbType.VarChar,10),
					new SqlParameter("@ReqCode", SqlDbType.VarChar,50),
					new SqlParameter("@RealPassword", SqlDbType.NVarChar,50),
					new SqlParameter("@CardType", SqlDbType.VarChar,2),
					new SqlParameter("@Country", SqlDbType.VarChar,50),
					new SqlParameter("@Province", SqlDbType.VarChar,50),
					new SqlParameter("@Fax", SqlDbType.VarChar,50),
					new SqlParameter("@RoamFlag", SqlDbType.Char,1),
					new SqlParameter("@RegCode", SqlDbType.VarChar,50),
					new SqlParameter("@LoginCount", SqlDbType.Int,4)};
            parameters[0].Value = model.RealName;
            parameters[1].Value = model.UserCode;
            parameters[2].Value = model.password;
            parameters[3].Value = model.UnitName;
            parameters[4].Value = model.DepartName;
            parameters[5].Value = model.UnitAddress;
            parameters[6].Value = model.Telephone;
            parameters[7].Value = model.PostCode;
            parameters[8].Value = model.Email;
            parameters[9].Value = model.IsHasExtend;
            parameters[10].Value = model.IsHasMap;
            parameters[11].Value = model.IsHasRole;
            parameters[12].Value = model.IdentificationCard;
            parameters[13].Value = model.CreateTime;
            parameters[14].Value = model.UserDescript;
            parameters[15].Value = model.IsManager;
            parameters[16].Value = model.RECFLAG;
            parameters[17].Value = model.UserFlag;
            parameters[18].Value = model.Sex;
            parameters[19].Value = model.JoinDate;
            parameters[20].Value = model.EndDate;
            parameters[21].Value = model.Question;
            parameters[22].Value = model.Answer;
            parameters[23].Value = model.IP;
            parameters[24].Value = model.Birth;
            parameters[25].Value = model.Positions;
            parameters[26].Value = model.Education;
            parameters[27].Value = model.LibraryCard;
            parameters[28].Value = model.CellPhone;
            parameters[29].Value = model.Jobs;
            parameters[30].Value = model.City;
            parameters[31].Value = model.County;
            parameters[32].Value = model.IPFrom;
            parameters[33].Value = model.IPTo;
            parameters[34].Value = model.UserRole;
            parameters[35].Value = model.RoleRight;
            parameters[36].Value = model.AppCode;
            parameters[37].Value = model.ReqCode;
            parameters[38].Value = model.RealPassword;
            parameters[39].Value = model.CardType;
            parameters[40].Value = model.Country;
            parameters[41].Value = model.Province;
            parameters[42].Value = model.Fax;
            parameters[43].Value = model.RoamFlag;
            parameters[44].Value = model.RegCode;
            parameters[45].Value = model.LoginCount;

            object obj = DbHelperSQL.ExecuteScalar(strSql.ToString(), parameters);
            if (obj == null)
            {
                return 0;
            }
            else
            {
                return Convert.ToInt32(obj);
            }
        }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(WinLib.Model.SSO_UserBaseInfo model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update SSO_UserBaseInfo set ");
            strSql.Append("RealName=@RealName,");
            strSql.Append("UserCode=@UserCode,");
            strSql.Append("password=@password,");
            strSql.Append("UnitName=@UnitName,");
            strSql.Append("DepartName=@DepartName,");
            strSql.Append("UnitAddress=@UnitAddress,");
            strSql.Append("Telephone=@Telephone,");
            strSql.Append("PostCode=@PostCode,");
            strSql.Append("Email=@Email,");
            strSql.Append("IsHasExtend=@IsHasExtend,");
            strSql.Append("IsHasMap=@IsHasMap,");
            strSql.Append("IsHasRole=@IsHasRole,");
            strSql.Append("IdentificationCard=@IdentificationCard,");
            strSql.Append("CreateTime=@CreateTime,");
            strSql.Append("UserDescript=@UserDescript,");
            strSql.Append("IsManager=@IsManager,");
            strSql.Append("RECFLAG=@RECFLAG,");
            strSql.Append("UserFlag=@UserFlag,");
            strSql.Append("Sex=@Sex,");
            strSql.Append("JoinDate=@JoinDate,");
            strSql.Append("EndDate=@EndDate,");
            strSql.Append("Question=@Question,");
            strSql.Append("Answer=@Answer,");
            strSql.Append("IP=@IP,");
            strSql.Append("Birth=@Birth,");
            strSql.Append("Positions=@Positions,");
            strSql.Append("Education=@Education,");
            strSql.Append("LibraryCard=@LibraryCard,");
            strSql.Append("CellPhone=@CellPhone,");
            strSql.Append("Jobs=@Jobs,");
            strSql.Append("City=@City,");
            strSql.Append("County=@County,");
            strSql.Append("IPFrom=@IPFrom,");
            strSql.Append("IPTo=@IPTo,");
            strSql.Append("UserRole=@UserRole,");
            strSql.Append("RoleRight=@RoleRight,");
            strSql.Append("AppCode=@AppCode,");
            strSql.Append("ReqCode=@ReqCode,");
            strSql.Append("RealPassword=@RealPassword,");
            strSql.Append("CardType=@CardType,");
            strSql.Append("Country=@Country,");
            strSql.Append("Province=@Province,");
            strSql.Append("Fax=@Fax,");
            strSql.Append("RoamFlag=@RoamFlag,");
            strSql.Append("RegCode=@RegCode,");
            strSql.Append("LoginCount=@LoginCount");
            strSql.Append(" where SYSID=@SYSID");
            SqlParameter[] parameters = {
					new SqlParameter("@RealName", SqlDbType.NVarChar,50),
					new SqlParameter("@UserCode", SqlDbType.NVarChar,50),
					new SqlParameter("@password", SqlDbType.NVarChar,50),
					new SqlParameter("@UnitName", SqlDbType.NVarChar,200),
					new SqlParameter("@DepartName", SqlDbType.NVarChar,200),
					new SqlParameter("@UnitAddress", SqlDbType.NVarChar,500),
					new SqlParameter("@Telephone", SqlDbType.NVarChar,50),
					new SqlParameter("@PostCode", SqlDbType.VarChar,50),
					new SqlParameter("@Email", SqlDbType.NVarChar,50),
					new SqlParameter("@IsHasExtend", SqlDbType.Int,4),
					new SqlParameter("@IsHasMap", SqlDbType.Int,4),
					new SqlParameter("@IsHasRole", SqlDbType.Int,4),
					new SqlParameter("@IdentificationCard", SqlDbType.VarChar,100),
					new SqlParameter("@CreateTime", SqlDbType.DateTime),
					new SqlParameter("@UserDescript", SqlDbType.NText),
					new SqlParameter("@IsManager", SqlDbType.Int,4),
					new SqlParameter("@RECFLAG", SqlDbType.Int,4),
					new SqlParameter("@UserFlag", SqlDbType.Int,4),
					new SqlParameter("@Sex", SqlDbType.Int,4),
					new SqlParameter("@JoinDate", SqlDbType.DateTime),
					new SqlParameter("@EndDate", SqlDbType.DateTime),
					new SqlParameter("@Question", SqlDbType.NVarChar,300),
					new SqlParameter("@Answer", SqlDbType.NVarChar,300),
					new SqlParameter("@IP", SqlDbType.VarChar,50),
					new SqlParameter("@Birth", SqlDbType.DateTime),
					new SqlParameter("@Positions", SqlDbType.VarChar,50),
					new SqlParameter("@Education", SqlDbType.VarChar,50),
					new SqlParameter("@LibraryCard", SqlDbType.VarChar,50),
					new SqlParameter("@CellPhone", SqlDbType.VarChar,50),
					new SqlParameter("@Jobs", SqlDbType.VarChar,50),
					new SqlParameter("@City", SqlDbType.VarChar,50),
					new SqlParameter("@County", SqlDbType.VarChar,50),
					new SqlParameter("@IPFrom", SqlDbType.VarChar,50),
					new SqlParameter("@IPTo", SqlDbType.VarChar,50),
					new SqlParameter("@UserRole", SqlDbType.Int,4),
					new SqlParameter("@RoleRight", SqlDbType.Int,4),
					new SqlParameter("@AppCode", SqlDbType.VarChar,10),
					new SqlParameter("@ReqCode", SqlDbType.VarChar,50),
					new SqlParameter("@RealPassword", SqlDbType.NVarChar,50),
					new SqlParameter("@CardType", SqlDbType.VarChar,2),
					new SqlParameter("@Country", SqlDbType.VarChar,50),
					new SqlParameter("@Province", SqlDbType.VarChar,50),
					new SqlParameter("@Fax", SqlDbType.VarChar,50),
					new SqlParameter("@RoamFlag", SqlDbType.Char,1),
					new SqlParameter("@RegCode", SqlDbType.VarChar,50),
					new SqlParameter("@LoginCount", SqlDbType.Int,4),
					new SqlParameter("@SYSID", SqlDbType.Int,4)};
            parameters[0].Value = model.RealName;
            parameters[1].Value = model.UserCode;
            parameters[2].Value = model.password;
            parameters[3].Value = model.UnitName;
            parameters[4].Value = model.DepartName;
            parameters[5].Value = model.UnitAddress;
            parameters[6].Value = model.Telephone;
            parameters[7].Value = model.PostCode;
            parameters[8].Value = model.Email;
            parameters[9].Value = model.IsHasExtend;
            parameters[10].Value = model.IsHasMap;
            parameters[11].Value = model.IsHasRole;
            parameters[12].Value = model.IdentificationCard;
            parameters[13].Value = model.CreateTime;
            parameters[14].Value = model.UserDescript;
            parameters[15].Value = model.IsManager;
            parameters[16].Value = model.RECFLAG;
            parameters[17].Value = model.UserFlag;
            parameters[18].Value = model.Sex;
            parameters[19].Value = model.JoinDate;
            parameters[20].Value = model.EndDate;
            parameters[21].Value = model.Question;
            parameters[22].Value = model.Answer;
            parameters[23].Value = model.IP;
            parameters[24].Value = model.Birth;
            parameters[25].Value = model.Positions;
            parameters[26].Value = model.Education;
            parameters[27].Value = model.LibraryCard;
            parameters[28].Value = model.CellPhone;
            parameters[29].Value = model.Jobs;
            parameters[30].Value = model.City;
            parameters[31].Value = model.County;
            parameters[32].Value = model.IPFrom;
            parameters[33].Value = model.IPTo;
            parameters[34].Value = model.UserRole;
            parameters[35].Value = model.RoleRight;
            parameters[36].Value = model.AppCode;
            parameters[37].Value = model.ReqCode;
            parameters[38].Value = model.RealPassword;
            parameters[39].Value = model.CardType;
            parameters[40].Value = model.Country;
            parameters[41].Value = model.Province;
            parameters[42].Value = model.Fax;
            parameters[43].Value = model.RoamFlag;
            parameters[44].Value = model.RegCode;
            parameters[45].Value = model.LoginCount;
            parameters[46].Value = model.SYSID;

            int rows = DbHelperSQL.ExecuteNonQuery(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(int SYSID)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from SSO_UserBaseInfo ");
            strSql.Append(" where SYSID=@SYSID");
            SqlParameter[] parameters = {
					new SqlParameter("@SYSID", SqlDbType.Int,4)
			};
            parameters[0].Value = SYSID;

            int rows = DbHelperSQL.ExecuteNonQuery(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        /// <summary>
        /// 批量删除数据
        /// </summary>
        public bool DeleteList(string SYSIDlist)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from SSO_UserBaseInfo ");
            strSql.Append(" where SYSID in (" + SYSIDlist + ")  ");
            int rows = DbHelperSQL.ExecuteNonQuery(strSql.ToString());
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }


        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public WinLib.Model.SSO_UserBaseInfo GetModel(int SYSID)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 SYSID,RealName,UserCode,password,UnitName,DepartName,UnitAddress,Telephone,PostCode,Email,IsHasExtend,IsHasMap,IsHasRole,IdentificationCard,CreateTime,UserDescript,IsManager,RECFLAG,UserFlag,Sex,JoinDate,EndDate,Question,Answer,IP,Birth,Positions,Education,LibraryCard,CellPhone,Jobs,City,County,IPFrom,IPTo,UserRole,RoleRight,AppCode,ReqCode,RealPassword,CardType,Country,Province,Fax,RoamFlag,RegCode,LoginCount from SSO_UserBaseInfo ");
            strSql.Append(" where SYSID=@SYSID");
            SqlParameter[] parameters = {
					new SqlParameter("@SYSID", SqlDbType.Int,4)
			};
            parameters[0].Value = SYSID;

            WinLib.Model.SSO_UserBaseInfo model = new WinLib.Model.SSO_UserBaseInfo();
            DataTable dt = DbHelperSQL.ExecuteQuery(strSql.ToString(), parameters);
            if (dt.Rows.Count > 0)
            {
                return DataRowToModel(dt.Rows[0]);
            }
            else
            {
                return null;
            }
        }


        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public WinLib.Model.SSO_UserBaseInfo DataRowToModel(DataRow row)
        {
            WinLib.Model.SSO_UserBaseInfo model = new WinLib.Model.SSO_UserBaseInfo();
            if (row != null)
            {
                if (row["SYSID"] != null && row["SYSID"].ToString() != "")
                {
                    model.SYSID = int.Parse(row["SYSID"].ToString());
                }
                if (row["RealName"] != null)
                {
                    model.RealName = row["RealName"].ToString();
                }
                if (row["UserCode"] != null)
                {
                    model.UserCode = row["UserCode"].ToString();
                }
                if (row["password"] != null)
                {
                    model.password = row["password"].ToString();
                }
                if (row["UnitName"] != null)
                {
                    model.UnitName = row["UnitName"].ToString();
                }
                if (row["DepartName"] != null)
                {
                    model.DepartName = row["DepartName"].ToString();
                }
                if (row["UnitAddress"] != null)
                {
                    model.UnitAddress = row["UnitAddress"].ToString();
                }
                if (row["Telephone"] != null)
                {
                    model.Telephone = row["Telephone"].ToString();
                }
                if (row["PostCode"] != null)
                {
                    model.PostCode = row["PostCode"].ToString();
                }
                if (row["Email"] != null)
                {
                    model.Email = row["Email"].ToString();
                }
                if (row["IsHasExtend"] != null && row["IsHasExtend"].ToString() != "")
                {
                    model.IsHasExtend = int.Parse(row["IsHasExtend"].ToString());
                }
                if (row["IsHasMap"] != null && row["IsHasMap"].ToString() != "")
                {
                    model.IsHasMap = int.Parse(row["IsHasMap"].ToString());
                }
                if (row["IsHasRole"] != null && row["IsHasRole"].ToString() != "")
                {
                    model.IsHasRole = int.Parse(row["IsHasRole"].ToString());
                }
                if (row["IdentificationCard"] != null)
                {
                    model.IdentificationCard = row["IdentificationCard"].ToString();
                }
                if (row["CreateTime"] != null && row["CreateTime"].ToString() != "")
                {
                    model.CreateTime = DateTime.Parse(row["CreateTime"].ToString());
                }
                if (row["UserDescript"] != null)
                {
                    model.UserDescript = row["UserDescript"].ToString();
                }
                if (row["IsManager"] != null && row["IsManager"].ToString() != "")
                {
                    model.IsManager = int.Parse(row["IsManager"].ToString());
                }
                if (row["RECFLAG"] != null && row["RECFLAG"].ToString() != "")
                {
                    model.RECFLAG = int.Parse(row["RECFLAG"].ToString());
                }
                if (row["UserFlag"] != null && row["UserFlag"].ToString() != "")
                {
                    model.UserFlag = int.Parse(row["UserFlag"].ToString());
                }
                if (row["Sex"] != null && row["Sex"].ToString() != "")
                {
                    model.Sex = int.Parse(row["Sex"].ToString());
                }
                if (row["JoinDate"] != null && row["JoinDate"].ToString() != "")
                {
                    model.JoinDate = DateTime.Parse(row["JoinDate"].ToString());
                }
                if (row["EndDate"] != null && row["EndDate"].ToString() != "")
                {
                    model.EndDate = DateTime.Parse(row["EndDate"].ToString());
                }
                if (row["Question"] != null)
                {
                    model.Question = row["Question"].ToString();
                }
                if (row["Answer"] != null)
                {
                    model.Answer = row["Answer"].ToString();
                }
                if (row["IP"] != null)
                {
                    model.IP = row["IP"].ToString();
                }
                if (row["Birth"] != null && row["Birth"].ToString() != "")
                {
                    model.Birth = DateTime.Parse(row["Birth"].ToString());
                }
                if (row["Positions"] != null)
                {
                    model.Positions = row["Positions"].ToString();
                }
                if (row["Education"] != null)
                {
                    model.Education = row["Education"].ToString();
                }
                if (row["LibraryCard"] != null)
                {
                    model.LibraryCard = row["LibraryCard"].ToString();
                }
                if (row["CellPhone"] != null)
                {
                    model.CellPhone = row["CellPhone"].ToString();
                }
                if (row["Jobs"] != null)
                {
                    model.Jobs = row["Jobs"].ToString();
                }
                if (row["City"] != null)
                {
                    model.City = row["City"].ToString();
                }
                if (row["County"] != null)
                {
                    model.County = row["County"].ToString();
                }
                if (row["IPFrom"] != null)
                {
                    model.IPFrom = row["IPFrom"].ToString();
                }
                if (row["IPTo"] != null)
                {
                    model.IPTo = row["IPTo"].ToString();
                }
                if (row["UserRole"] != null && row["UserRole"].ToString() != "")
                {
                    model.UserRole = int.Parse(row["UserRole"].ToString());
                }
                if (row["RoleRight"] != null && row["RoleRight"].ToString() != "")
                {
                    model.RoleRight = int.Parse(row["RoleRight"].ToString());
                }
                if (row["AppCode"] != null)
                {
                    model.AppCode = row["AppCode"].ToString();
                }
                if (row["ReqCode"] != null)
                {
                    model.ReqCode = row["ReqCode"].ToString();
                }
                if (row["RealPassword"] != null)
                {
                    model.RealPassword = row["RealPassword"].ToString();
                }
                if (row["CardType"] != null)
                {
                    model.CardType = row["CardType"].ToString();
                }
                if (row["Country"] != null)
                {
                    model.Country = row["Country"].ToString();
                }
                if (row["Province"] != null)
                {
                    model.Province = row["Province"].ToString();
                }
                if (row["Fax"] != null)
                {
                    model.Fax = row["Fax"].ToString();
                }
                if (row["RoamFlag"] != null)
                {
                    model.RoamFlag = row["RoamFlag"].ToString();
                }
                if (row["RegCode"] != null)
                {
                    model.RegCode = row["RegCode"].ToString();
                }
                if (row["LoginCount"] != null && row["LoginCount"].ToString() != "")
                {
                    model.LoginCount = int.Parse(row["LoginCount"].ToString());
                }
            }
            return model;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataTable GetList(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select SYSID,RealName,UserCode,password,UnitName,DepartName,UnitAddress,Telephone,PostCode,Email,IsHasExtend,IsHasMap,IsHasRole,IdentificationCard,CreateTime,UserDescript,IsManager,RECFLAG,UserFlag,Sex,JoinDate,EndDate,Question,Answer,IP,Birth,Positions,Education,LibraryCard,CellPhone,Jobs,City,County,IPFrom,IPTo,UserRole,RoleRight,AppCode,ReqCode,RealPassword,CardType,Country,Province,Fax,RoamFlag,RegCode,LoginCount ");
            strSql.Append(" FROM SSO_UserBaseInfo ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            return DbHelperSQL.ExecuteQuery(strSql.ToString());
        }

        /// <summary>
        /// 获得前几行数据
        /// </summary>
        public DataTable GetList(int Top, string strWhere, string filedOrder)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select ");
            if (Top > 0)
            {
                strSql.Append(" top " + Top.ToString());
            }
            strSql.Append(" SYSID,RealName,UserCode,password,UnitName,DepartName,UnitAddress,Telephone,PostCode,Email,IsHasExtend,IsHasMap,IsHasRole,IdentificationCard,CreateTime,UserDescript,IsManager,RECFLAG,UserFlag,Sex,JoinDate,EndDate,Question,Answer,IP,Birth,Positions,Education,LibraryCard,CellPhone,Jobs,City,County,IPFrom,IPTo,UserRole,RoleRight,AppCode,ReqCode,RealPassword,CardType,Country,Province,Fax,RoamFlag,RegCode,LoginCount ");
            strSql.Append(" FROM SSO_UserBaseInfo ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            strSql.Append(" order by " + filedOrder);
            return DbHelperSQL.ExecuteQuery(strSql.ToString());
        }

        /// <summary>
        /// 获取记录总数
        /// </summary>
        public int GetRecordCount(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) FROM SSO_UserBaseInfo ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            object obj = DbHelperSQL.ExecuteScalar(strSql.ToString());
            if (obj == null)
            {
                return 0;
            }
            else
            {
                return Convert.ToInt32(obj);
            }
        }
        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public DataTable GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("SELECT * FROM ( ");
            strSql.Append(" SELECT ROW_NUMBER() OVER (");
            if (!string.IsNullOrEmpty(orderby.Trim()))
            {
                strSql.Append("order by T." + orderby);
            }
            else
            {
                strSql.Append("order by T.SYSID desc");
            }
            strSql.Append(")AS Row, T.*  from SSO_UserBaseInfo T ");
            if (!string.IsNullOrEmpty(strWhere.Trim()))
            {
                strSql.Append(" WHERE " + strWhere);
            }
            strSql.Append(" ) TT");
            strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
            return DbHelperSQL.ExecuteQuery(strSql.ToString());
        }

        /*
        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public DataSet GetList(int PageSize,int PageIndex,string strWhere)
        {
            SqlParameter[] parameters = {
                    new SqlParameter("@tblName", SqlDbType.VarChar, 255),
                    new SqlParameter("@fldName", SqlDbType.VarChar, 255),
                    new SqlParameter("@PageSize", SqlDbType.Int),
                    new SqlParameter("@PageIndex", SqlDbType.Int),
                    new SqlParameter("@IsReCount", SqlDbType.Bit),
                    new SqlParameter("@OrderType", SqlDbType.Bit),
                    new SqlParameter("@strWhere", SqlDbType.VarChar,1000),
                    };
            parameters[0].Value = "SSO_UserBaseInfo";
            parameters[1].Value = "SYSID";
            parameters[2].Value = PageSize;
            parameters[3].Value = PageIndex;
            parameters[4].Value = 0;
            parameters[5].Value = 0;
            parameters[6].Value = strWhere;	
            return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds");
        }*/

        #endregion  BasicMethod
        #region  ExtensionMethod

        #endregion  ExtensionMethod
    }
}

